<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <link rel="stylesheet" href="../../lib/jq-module/zyupload/zyupload-1.0.0.min.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }

    </style>
</head>
<body>
<div class="layui-form layuimini-form" lay-filter="job-form">
    <div class="layui-form-item">
        <label class="layui-form-label">订单编号</label>
        <div class="layui-input-block">
            <input type="text" name="orderId" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">订单状态</label>
        <div class="layui-input-block">
            <input type="text" name="orderStatus" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">交易时间</label>
        <div class="layui-input-block">
            <input type="text" name="joinTime" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">发货时间</label>
        <div class="layui-input-block">
            <input type="text" name="deliveryTime" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">物流公司</label>
        <div class="layui-input-block">
            <input type="text" name="courierName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">物流单号</label>
        <div class="layui-input-block">
            <input type="text" name="courierNumber" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">商品名称</label>
        <div class="layui-input-block">
            <input type="text" name="goodsName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">发货链接</label>
        <div class="layui-input-block">
            <input type="text" name="shippingLink" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">商品规格</label>
        <div class="layui-input-block">
            <input type="text" name="specification" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">玫丽价（元）</label>
        <div class="layui-input-block">
            <input type="text" name="unitPrice" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">供货价（元）</label>
        <div class="layui-input-block">
            <input type="text" name="supplyPrice" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">实际供货价（元）</label>
        <div class="layui-input-block">
            <input type="text" name="realSupplyPrice" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">收货人</label>
        <div class="layui-input-block">
            <input type="text" name="consigneeName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input type="text" name="consigneePhoneNum" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">购买数量</label>
        <div class="layui-input-block">
            <input type="text" name="buyQuantity" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">实付金额（元）</label>
        <div class="layui-input-block">
            <input type="text" name="payAmount" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">订单备注</label>
        <div class="layui-input-block">
            <input type="text" name="orderRemarks" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">收货地址</label>
        <div class="layui-input-block">
            <input type="text" name="consigneeAddress" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">消费者</label>
        <div class="layui-input-block">
            <input type="text" name="partnerName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">代理区域服务商</label>
        <div class="layui-input-block">
            <input type="text" name="initiatorName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">代理销售佣金（元）</label>
        <div class="layui-input-block">
            <input type="text" name="sceneId" disabled="disabled" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选址区域服务商</label>
        <div class="layui-input-block">
            <input type="text" name="providerName" disabled="disabled" value="" class="layui-input">
        </div>
    </div>

</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../../lib/common/common.js" charset="utf-8"></script>
<script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="../../js/lay-module/xm-select-master/dist/xm-select.js" charset="utf-8"></script>

<script>

    window.onload = function () {
        let recordId = GetQueryString("recordId");
        if (isNotNull(recordId)) {
            init(recordId);
        } else {
            layer.msg("数据异常，请重试");
            // 关闭弹出层
            setTimeout(function () {
                let iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);
            }, 1500);
        }
    }

    /**
     * 初始化数据
     */
    function init(recordId) {
        $.ajax({
            type: "get",
            url: '/buying/get/' + recordId,
            dataType: 'json',
            contentType: 'application/x-www-form-urlencoded',
            success: function (req) {
                if (req.code === '200') {
                    let addressObj
                    try {
                        addressObj = JSON.parse(req.data.address);
                    } catch (e) {
                        layer.msg("数据异常，请重试");
                        // 关闭弹出层
                        setTimeout(function () {
                            let iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                        }, 1500);
                    }
                    let consigneeName = addressObj.Name ? addressObj.Name : '';
                    let consigneePhoneNum = addressObj.PhoneNum ? addressObj.PhoneNum : '';
                    let consigneeAddress = "";
                    if (addressObj.Region) {
                        consigneeAddress = addressObj.Region;
                        if (addressObj.StreetVillage) {
                            consigneeAddress += "-" + addressObj.StreetVillage;
                            if (addressObj.Address) {
                                consigneeAddress += " " + addressObj.Address;
                            }
                        }
                    }
                    layui.use(['form'], function () {
                        let form = layui.form
                        let offlineProvider = req.data.offlineProvider;
                        let offlineProviderName = ("（未注册）");
                        if (offlineProvider) {
                            offlineProviderName = offlineProvider.nickName + '（NO.' + offlineProvider.providerId + '）'
                        }
                        let onlineProvider = req.data.onlineProvider;
                        let onlineProviderName = ("（未注册）");
                        if (onlineProvider) {
                            onlineProviderName = onlineProvider.nickName + '（NO.' + onlineProvider.providerId + '）'
                        }
                        form.val('job-form', {
                            "orderId": req.data.orderId,
                            "orderStatus": req.data.orderStatus,
                            "courierName": req.data.courierName,
                            "courierNumber": req.data.courierNumber,
                            "joinTime": req.data.joinTime,
                            "partnerName": req.data.partnerName + "（" + req.data.partnerId + "）",
                            "goodsName": req.data.goodsName + "（" + req.data.goodsNo + "）",
                            "unitPrice": req.data.unitPrice,
                            "buyQuantity": req.data.buyQuantity,
                            "payAmount": req.data.payAmount,
                            "deliveryTime": req.data.deliveryTime,
                            "orderRemarks": req.data.orderRemarks,
                            "specification": req.data.specification,
                            "supplyPrice": req.data.supplyPrice,
                            "realSupplyPrice": req.data.realSupplyPrice,
                            "consigneeName": consigneeName,
                            "consigneePhoneNum": consigneePhoneNum,
                            "consigneeAddress": consigneeAddress,
                            "initiatorName": onlineProviderName,
                            "sceneId": req.data.sceneId,
                            "providerName": offlineProviderName
                        })
                        ;
                    })
                } else {
                    layer.msg("数据异常，请重试");
                    // 关闭弹出层
                    setTimeout(function () {
                        let iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                    }, 1500);
                }
            },
            error: function (e) {
                layer.msg("数据有误");
            }
        })
    }
</script>
</body>
</html>